﻿

#region Using directives
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Indeco.G24.Web.UI;
#endregion
namespace Indeco.G24.Website.Admin
{
    public partial class TinTuc : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            FormUtil.RedirectAfterUpdate(GridView1, "TinTuc.aspx?page={0}");
            FormUtil.SetPageIndex(GridView1, "page");
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string urlParams = string.Format("IDTinTuc={0}", GridView1.SelectedDataKey.Values[0]);
            Response.Redirect("TinTucEdit.aspx?" + urlParams, true);
        }


        [System.Web.Script.Services.ScriptMethod]
        [System.Web.Services.WebMethod]
        public static string GetMoTaContent(string contextKey)
        {
            System.Guid key;
            Indeco.G24.Entities.EntityUtil.GuidTryParse(contextKey, out key);

            Indeco.G24.Entities.TinTuc content
                = Indeco.G24.Data.DataRepository.TinTucProvider.GetByIDTinTuc(key);

            if (content == null)
                return "No Content Found!";

            return string.Format("<div id='previewContent'>{0}</div>", content.MoTa);
        }

        [System.Web.Script.Services.ScriptMethod]
        [System.Web.Services.WebMethod]
        public static string GetNoiDungContent(string contextKey)
        {
            System.Guid key;
            Indeco.G24.Entities.EntityUtil.GuidTryParse(contextKey, out key);

            Indeco.G24.Entities.TinTuc content
                = Indeco.G24.Data.DataRepository.TinTucProvider.GetByIDTinTuc(key);

            if (content == null)
                return "No Content Found!";

            return string.Format("<div id='previewContent'>{0}</div>", content.NoiDung);
        }
    }
}


